<template>
	<view class="container">
		<!-- 动态粒子背景 -->
		<view class="particles-bg" id="particles-js"></view>

		<!-- 渐变波浪背景 -->
		<view class="wave-bg">
			<svg viewBox="0 0 1200 120" preserveAspectRatio="none">
				<path
					d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.21,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z"
					opacity=".25" fill="url(#wave-gradient)"></path>
				<path
					d="M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z"
					opacity=".5" fill="url(#wave-gradient)"></path>
				<path
					d="M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z"
					fill="url(#wave-gradient)"></path>
				<defs>
					<linearGradient id="wave-gradient" x1="0%" y1="0%" x2="100%" y2="0%">
						<stop offset="0%" stop-color="#4a8fe7" />
						<stop offset="100%" stop-color="#6a5acd" />
					</linearGradient>
				</defs>
			</svg>
		</view>

		<!-- 主要内容 -->
		<view class="content">
			<!-- 动态旋转的logo -->
			<image src="../../static/logo.png" class="logo animate__animated animate__zoomIn animate__delay-0.1s"
				mode="aspectFit" @click="rotateLogo"></image>

			<!-- 标题 -->
			<view class="text-area animate__animated animate__fadeInDown animate__delay-0.2s">
				<h1 class="title">{{ title }}</h1>
				<text class="subtitle">专业教育管理平台</text>
				<view class="animated-underline"></view>
			</view>

			<!-- 功能按钮区域 -->
			<view class="button-grid">
				<view v-for="(btn, index) in buttons" :key="index" class="button-card"
					:class="`animate__animated animate__fadeInUp animate__delay-${index*0.1 + 0.3}s`"
					@click="btn.handler" @touchstart="buttonTouchStart(index)" @touchend="buttonTouchEnd(index)"
					:style="{transform: buttonScales[index]}">
					<view class="button-icon">
						<uni-icons :type="btn.icon" size="28" color="#fff"></uni-icons>
					</view>
					<text class="button-text">{{ btn.text }}</text>
					<view class="button-hover-effect"></view>
				</view>
			</view>

			<!-- 底部波浪装饰 -->
			<view class="bottom-wave">
				<svg viewBox="0 0 1200 120" preserveAspectRatio="none">
					<path
						d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.21,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z"
						opacity=".1" fill="url(#wave-gradient)"></path>
				</svg>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '大辛辅导班管理后台',
				buttons: [

					{
						text: '学生管理',
						icon: 'contact',
						handler: this.add
					},
					{
						text: '老师管理',
						icon: 'staff',
						handler: this.list
					},
					{
						text: '预约管理',
						icon: 'calendar',
						handler: this.chars
					},
					{
						text: '零食管理',
						icon: 'cart',
						handler: this.snake
					}, {
						text: '文章管理',
						icon: 'compose',
						handler: this.page
					},
					{
						text: '课程管理',
						icon: 'list',
						handler: this.address
					},
					{
						text: '家访抽签',
						icon: 'help',
						handler: this.check
					},
					// {
					// 	text: '零食管理',
					// 	icon: 'cart',
					// 	handler: this.snake
					// }
				],
				buttonScales: Array(7).fill('scale(1)')
			}
		},
		methods: {
			snake() {
				uni.navigateTo({
					url: "/pages/snake/snake"
				})
			},
			page() {
				uni.navigateTo({
					url: "/pages/editor/editor"
				})
			},
			check() {
				uni.navigateTo({
					url: "/pages/chouqian/chouqian"
				})
			},
			address() {
				uni.navigateTo({
					url: "/pages/address/address"
				})
			},
			chars() {
				uni.navigateTo({
					url: "/pages/appointmentIndex/appointmentIndex"
				})
			},
			add() {
				uni.navigateTo({
					url: "/pages/student/student"
				})
			},
			list() {
				uni.navigateTo({
					url: "/pages/teacher/teacher"
				})
			},
			rotateLogo() {
				const logo = document.querySelector('.logo');
				logo.classList.add('animate__rotateIn');
				setTimeout(() => {
					logo.classList.remove('animate__rotateIn');
				}, 1000);
			},
			buttonTouchStart(index) {
				this.$set(this.buttonScales, index, 'scale(0.95)');
			},
			buttonTouchEnd(index) {
				this.$set(this.buttonScales, index, 'scale(1)');
			}
		},
		mounted() {
			// 模拟粒子效果
			if (typeof document !== 'undefined') {
				const style = document.createElement('style');
				style.innerHTML = `
					.particles-bg::before {
						content: '';
						position: absolute;
						top: 0;
						left: 0;
						width: 100%;
						height: 100%;
						background: radial-gradient(circle at 20% 50%, rgba(74, 143, 231, 0.1) 0%, transparent 50%),
									radial-gradient(circle at 80% 30%, rgba(106, 90, 205, 0.1) 0%, transparent 50%);
						animation: particleMove 20s infinite alternate;
					}
					
					@keyframes particleMove {
						0% { transform: translate(0, 0); }
						100% { transform: translate(50px, 30px); }
					}
				`;
				document.head.appendChild(style);
			}
		}
	}
</script>

<style lang="scss">
	@import url("https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css");

	.container {
		position: relative;
		min-height: 100vh;
		background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ed 100%);
		overflow: hidden;
	}

	.particles-bg {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 0;
		overflow: hidden;
	}

	.wave-bg {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 200px;
		overflow: hidden;
		z-index: 1;

		svg {
			display: block;
			width: 100%;
			height: 100%;
		}
	}

	.content {
		position: relative;
		z-index: 2;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		min-height: 100vh;
		padding: 20px;
		padding-top: 60px;
	}

	.logo {
		width: 180px;
		height: 180px;
		border-radius: 50%;
		box-shadow: 0 15px 35px rgba(74, 143, 231, 0.3);
		border: 5px solid rgba(255, 255, 255, 0.9);
		margin-bottom: 25px;
		transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
		background: white;
		backdrop-filter: blur(5px);
		-webkit-backdrop-filter: blur(5px);

		&:hover {
			transform: scale(1.05) rotate(5deg);
			box-shadow: 0 20px 40px rgba(74, 143, 231, 0.4);
		}
	}

	.text-area {
		text-align: center;
		margin-bottom: 40px;
		position: relative;

		.title {
			font-size: 32px;
			font-weight: bold;
			color: #333;
			margin-bottom: 8px;
			text-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
			background: linear-gradient(135deg, #4a8fe7, #6a5acd);
			-webkit-background-clip: text;
			background-clip: text;
			color: transparent;
			letter-spacing: 1px;
		}

		.subtitle {
			font-size: 16px;
			color: #666;
			letter-spacing: 3px;
			text-transform: uppercase;
			font-weight: 500;
		}

		.animated-underline {
			height: 3px;
			width: 80px;
			background: linear-gradient(90deg, #4a8fe7, #6a5acd);
			margin: 15px auto 0;
			border-radius: 3px;
			animation: underlinePulse 2s infinite ease-in-out;
		}
	}

	.button-grid {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 20px;
		width: 100%;
		max-width: 500px;
		margin-bottom: 40px;
	}

	.button-card {
		position: relative;
		background: linear-gradient(135deg, rgba(74, 143, 231, 0.9), rgba(106, 90, 205, 0.9));
		border-radius: 16px;
		padding: 25px 15px;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		box-shadow: 0 8px 25px rgba(74, 143, 231, 0.3);
		transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
		cursor: pointer;
		overflow: hidden;
		backdrop-filter: blur(5px);
		-webkit-backdrop-filter: blur(5px);
		border: 1px solid rgba(255, 255, 255, 0.2);

		&:hover {
			transform: translateY(-5px) scale(1.02);
			box-shadow: 0 12px 30px rgba(74, 143, 231, 0.4);
		}

		&:active {
			transform: translateY(0) scale(0.98);
		}

		.button-icon {
			width: 60px;
			height: 60px;
			border-radius: 50%;
			background: rgba(255, 255, 255, 0.2);
			display: flex;
			align-items: center;
			justify-content: center;
			margin-bottom: 15px;
			transition: all 0.3s ease;
		}

		.button-text {
			color: white;
			font-size: 16px;
			font-weight: 500;
			letter-spacing: 1px;
			position: relative;
			z-index: 2;
		}

		.button-hover-effect {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			background: radial-gradient(circle at center, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
			opacity: 0;
			transition: opacity 0.3s ease;
		}

		&:hover .button-hover-effect {
			opacity: 1;
		}
	}

	.bottom-wave {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 100px;
		overflow: hidden;
		z-index: 1;

		svg {
			display: block;
			width: 100%;
			height: 100%;
		}
	}

	/* 动画效果 */
	.animate__animated {
		--animate-duration: 0.8s;
	}

	@keyframes underlinePulse {
		0% {
			transform: scaleX(1);
			opacity: 1;
		}

		50% {
			transform: scaleX(1.2);
			opacity: 0.7;
		}

		100% {
			transform: scaleX(1);
			opacity: 1;
		}
	}

	@keyframes float {
		0% {
			transform: translateY(0px);
		}

		50% {
			transform: translateY(-10px);
		}

		100% {
			transform: translateY(0px);
		}
	}

	/* 响应式调整 */
	@media (min-width: 768px) {
		.button-grid {
			grid-template-columns: repeat(3, 1fr);
			max-width: 700px;
		}

		.logo {
			width: 220px;
			height: 220px;
		}

		.text-area {
			.title {
				font-size: 40px;
			}

			.subtitle {
				font-size: 18px;
			}
		}

		.button-card {
			padding: 30px 20px;

			.button-text {
				font-size: 18px;
			}
		}
	}
</style>